<template>
  <div>
    <Tree :list="list" @click="onClick"></Tree>
  </div>
</template>
<script>
import Tree from "./tree.vue";
export default {
  name: "Menu",
  props: ["list"],
  components: {
    Tree,
  },
  data() {
    return {};
  },
  methods: {
    // 点击事件
    onClick(id) {
      // this.id = id;
      console.log(id);
      // if (this.sArr) {
      //   this.sArr = this.sArr.map((item) => {
      //     if (item.id == id) item.active = true;
      //     return item;
      //   });
      //   console.log("书籍：", this.list);
      // }
      // this.tree(this.sArr || this.list);
    },
    // 递归
    tree(arr) {
      console.log(arr);
      arr.forEach((item) => {
        // item.maxHeight = 100;

        if (item[this.children]) {
          console.log(item.id, item[this.children]);
          this.tree(item[this.children]);
        }
      });
    },
  },
};
</script>